package jp.tkym.labs.store;

import java.util.Iterator;

import com.google.appengine.api.datastore.Entity;

/**
 * 
 * @author kazunari
 * 
 * @param <T>
 */
class GoogleQueryIterator<T> implements Iterator<T> {
	private Iterator<Entity> iterator;
	private EntityResolver<T> resolver;

	/**
	 * Constructor
	 * 
	 * @param resolver
	 * @param iterator
	 */
	GoogleQueryIterator(EntityResolver<T> resolver,
			Iterator<Entity> iterator) {
		this.resolver = resolver;
		this.iterator = iterator;
	}

	@Override
	public boolean hasNext() {
		return iterator.hasNext();
	}

	@Override
	public T next() {
		return resolver.toBean(iterator.next());
	}

	@Override
	public void remove() {
		iterator.remove();
	}
}